import React, {useEffect, useState} from 'react';
import useTable from "@/cms/use/useTable";
import {Button, message, Modal, Space} from "antd";
import {orderStatusList, useRooms} from "@/pages/constant";
import useFilter from "@/cms/use/useFilter";
import dayjs from "dayjs";

function Orders(props) {
    const {roomList} = useRooms({companyId:window.company_id})

    const {queryList,tableDOM} = useTable({
        columns:[
            {
                title:"会员名",
                render(_,record={}){
                    return record.memberDetail.name||"-"
                }
            },{
                title:"会员ID",
                dataIndex: "wxId"
            },{
                title:"充值金额",
                dataIndex:"payment",
            },{
                title:"到账金额",
                dataIndex:"balance",
            },{
                title:"充值时间",
                dataIndex:"CreatedAt",
                render(text){
                    return dayjs(text).format("YYYY-MM-DD HH:mm")
                }
            },{
                title:"过期时间",
                dataIndex:"endTime",
                render(text) {
                    return text || "-";
                }
            },
        ],
        xhr:{
            query:"/app/orderList",
        },
        extraParams:{
            type:2
        }
    })
    const {FilterDOM} = useFilter({
        queryList,
        list:[
            {
              label:"会员ID",
              name:"wxId"
            },
            {
                label:"状态",
                name:"status",
                type:"select",
                options:orderStatusList
            }
        ]
    })

    return (
        <div>
            {FilterDOM}
            {tableDOM}
        </div>
    );
}

export default Orders;